package com.chuck.cloud.oauth.config;

import com.chuck.basic.boot.config.BaseConfig;
import com.chuck.basic.log.event.SysLogListener;
import com.chuck.cloud.authority.biz.service.common.OptLogService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zuihou
 * @date 2017-12-15 14:42
 */
@Configuration
public class OauthWebConfiguration extends BaseConfig {

    /**
     * chuck.log.enabled = true 并且 chuck.log.type=DB时实例该类
     */
    @Bean
    @ConditionalOnExpression("${chuck.log.enabled:true} && 'DB'.equals('${chuck.log.type:LOGGER}')")
    public SysLogListener sysLogListener(OptLogService optLogService) {
        return new SysLogListener(optLogService::save);
    }
}
